<meta charset="utf-8">
<title>会员管理</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<meta name="description" content="网站描述">
<meta name="keywords" content="">
<meta name="author" content="wangl">
<link rel="icon" href="http://ow9lg82yy.bkt.clouddn.com/24f5c360-485d-4a6d-9468-2a61c353cf37.ico">
<link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
<link rel="stylesheet" href="//at.alicdn.com/t/font_tnyc012u2rlwstt9.css" media="all">
<link rel="stylesheet" href="/static/css/user.css" media="all">
<link rel="stylesheet" href="/static/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">

<style>
    * {
        margin: 0;
        padding: 0;
    }

    #ele {
        padding: 20px
    }

    .clearfix::after {
        content: ".";
        clear: both;
        display: block;
        overflow: hidden;
        font-size: 0;
        height: 0;
    }

    .clearfix {
        zoom: 1;
    }

    .Pagination ul {
        list-style: none;
    }

    .Pagination .total_num, .first_page, .prepage, .list_box, .nextpage, .last_page, .total_page, input, .redir {
        float: left;
    }

    .Pagination ul li {
        float: left;
        background-color: #ccc;
        border-radius: 5px;
        text-align: center;
        line-height: 22px;
        width: 22px;
        height: 22px;
        font-size: 12px;
        margin: 0 5px;
        cursor: pointer;
        color: #8b8b8b
    }

    .Pagination ul li:hover {
        background-color: #58acf4;
        color: #fff;
    }

    .Pagination .total_num {
        margin: 0 5px;
    }

    .Pagination .total_num i {
        font-style: normal;
    }

    .Pagination .list_box {
        width: 320px;
        overflow: hidden;
        position: relative;
        height: 32px;
    }

    .Pagination .list_box ul {
        position: absolute;
        top: 0;
        left: 0;
    }

    .Pagination .prepage {
        background-color: #ccc;
        border-radius: 5px;
        padding: 3px 10px;
        font-size: 12px;
        margin: 0 5px;
        cursor: pointer;
        color: #8b8b8b
    }

    .Pagination .prepage:hover {
        background-color: #58acf4;
        color: #fff;
    }

    .Pagination .nextpage {
        background-color: #ccc;
        border-radius: 5px;
        padding: 3px 10px;
        font-size: 12px;
        margin: 0 5px;
        cursor: pointer;
        color: #8b8b8b
    }

    .Pagination .nextpage:hover {
        background-color: #58acf4;
        color: #fff;
    }

    .Pagination .first_page {
        background-color: #ccc;
        border-radius: 5px;
        padding: 3px 10px;
        font-size: 12px;
        margin: 0 5px;
        cursor: pointer;
        color: #8b8b8b
    }

    .Pagination .first_page:hover {
        background-color: #58acf4;
        color: #fff;
    }

    .Pagination .last_page {
        background-color: #ccc;
        border-radius: 5px;
        padding: 3px 10px;
        font-size: 12px;
        margin: 0 5px;
        cursor: pointer;
        color: #8b8b8b
    }

    .Pagination .last_page:hover {
        background-color: #58acf4;
        color: #fff;
    }

    .Pagination .redir {
        background-color: #58acf4;
        color: #fff;
        border-radius: 5px;
        padding: 3px 10px;
        font-size: 14px;
        cursor: pointer;
    }

    .Pagination .redir:hover {
        opacity: 0.8;
    }

    .Pagination input {
        width: 50px;
        height: 25px;
        border-radius: 5px;
        border: 1px solid #ccc;
        outline: none;
        text-indent: 5px;
        margin: 0 5px;
    }

    .Pagination .short {
        background-color: #fff;
        cursor: default;
    }

    .Pagination .short:hover {
        background-color: #fff;
        color: #8b8b8b;
    }

    .Pagination_active {
        background-color: #58acf4 !important;
        color: #fff !important;
    }

    .detail-body {
        margin: 20px 0 0;
        min-height: 306px;
        line-height: 26px;
        font-size: 16px;
        color: #333;
        word-wrap: break-word;
    }

    /* blockquote 样式 */
    blockquote {
        display: block;
        border-left: 8px solid #d0e5f2;
        padding: 5px 10px;
        margin: 10px 0;
        line-height: 1.4;
        font-size: 100%;
        background-color: #f1f1f1;
    }

    /***
    *  ztree 图标变成黄色
    */
    .ztree .line {
        line-height: 0;
        border-top: none;
        float: none;
    }

    .ztree li span.button.ico_docu {
        background-position: -110px 0;
        margin-right: 2px;
        vertical-align: top;
    }

    /* code 样式 */
    code {
        display: inline-block;
        *display: inline;
        *zoom: 1;
        background-color: #f1f1f1;
        border-radius: 3px;
        padding: 3px 5px;
        margin: 0 3px;
    }

    pre code {
        display: block;
    }
    .layui-table-cell{ padding: 0 5px;}
    .layui-table td, .layui-table th{ padding: 9px 5px;}
</style>

</head>
<body class="childrenBody">
<div class="layui-col-xs2">
    <div class="grid-demo grid-demo-bg1">
        <ul id="treeDemo" class="ztree"></ul>
    </div>
</div>
<div class="layui-col-xs12">
    <fieldset class="layui-elem-field">
        <legend>会员列表</legend>
        <div class="layui-field-box">
            <form class="layui-form" id="searchForm" action="">
                <div class="layui-inline" style="margin-left: 15px">
                    <label>姓名:</label>
                    <div class="layui-input-inline">
                        <input id="userName" type="text" value="" name="userName" placeholder="姓名"
                               class="layui-input search_input">
                    </div>
                </div>
                <div class="layui-inline" style="margin-left: 15px">
                    <label>手机号:</label>
                    <div class="layui-input-inline">
                        <input id="phoneNum" type="text" value="" name="phoneNum" placeholder="手机号"
                               class="layui-input search_input">
                    </div>
                </div>
                <div class="layui-inline" style="margin-left: 15px">
                    <label>证件号码:</label>
                    <div class=" layui-input-inline">
                        <input id="idCardNum" type="text" value="" name="idCardNum" placeholder="证件号码"
                               class="layui-input search_input">
                    </div>
                </div>
                <div class="layui-inline">
                    <button type="button" class="layui-btn" onclick="search()">搜索</button>
                </div>
                <div class="layui-inline">
                    <#--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                </div>
                <#--<div class="layui-inline">-->
                <#--<a href="addpage" class="layui-btn layui-btn-normal" data-type="addBlogArticle">新增会员</a>-->
                <#--</div>-->
            </form>
            <form class="layui-form" id="siftForm">
                <div>
                    <div class="layui-inline" style="margin-left: 15px">
                        <label>交易完成量:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="minDealedCount" id="minDealedCount" lay-verify="date"
                                   autocomplete="off" class="layui-input" lay-key="1">
                        </div>
                        <span>-</span>
                        <div class="layui-input-inline">
                            <input type="text" name="maxDealedCount" id="maxDealedCount" lay-verify="date"
                                   autocomplete="off" class="layui-input" lay-key="1">
                        </div>
                    </div>
                    <div class="layui-inline" style="margin-left: 15px">
                        <label>活币数量区间:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="minAliveCoinCount" id="minAliveCoinCount" lay-verify="date"
                                   autocomplete="off" class="layui-input" lay-key="1">
                        </div>
                        <span>-</span>
                        <div class="layui-input-inline">
                            <input type="text" name="maxAliveCoinCount" id="maxAliveCoinCount" lay-verify="date"
                                   autocomplete="off" class="layui-input" lay-key="2">
                        </div>
                    </div>
                    <div class="layui-inline" style="margin-left: 15px">
                        <label>注册时间区间:</label>
                        <div class="layui-inline">
                            <input type="text" class="layui-input" id="startRegisterTime" name="startRegisterTime"
                                   lay-verify="date">
                        </div>
                        <span>-</span>
                        <div class="layui-inline">
                            <input type="text" class="layui-input" name="endRegisterTime" id="endRegisterTime"
                                   lay-verify="date">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button type="button" onclick="getMemberList()" class="layui-btn">筛选</button>
                    </div>
                    <div class="layui-inline">
                        <#--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                    </div>
                </div>
            </form>

        </div>

    </fieldset>
    <div class="layui-form users_list">

                        <table cellspacing="0" cellpadding="0" border="0" class="layui-table">
                            <thead>
                            <tr>
                                <#--UID、姓名、手机号、活币持有量、累计交易量、累计交易金额、累计转账、用户状态、注册日期、操作-->
                                <th data-field="userId">
                                    <div class="layui-table-cell laytable-cell-1-anid1"><span>编号</span></div>
                                </th>
                                <th data-field="userRealName">
                                    <div class="layui-table-cell laytable-cell-1-title"><span>姓名</span></div>
                                </th>
                                <th data-field="phoneNum">
                                    <div class="layui-table-cell laytable-cell-1-title"><span>手机号</span></div>
                                </th>
                                <th data-field="eMail">
                                    <div class="layui-table-cell laytable-cell-1-title"><span>邮箱</span></div>
                                </th>
                                <th data-field="userState">
                                    <div class="layui-table-cell laytable-cell-1-anid90"><span>用户状态</span></div>
                                </th>
                                <th data-field="capitalState">
                                    <div class="layui-table-cell laytable-cell-1-anid90"><span>钱包状态</span></div>
                                </th>
                                <th data-field="aliveCount">
                                    <div class="layui-table-cell laytable-cell-1-anid100"><span>活币持有量</span></div>
                                </th>
                                <th data-field="aliveCount">
                                    <div class="layui-table-cell laytable-cell-1-anid100"><span>冻结活币量</span></div>
                                </th>
                                <th data-field="totalDeal">
                                    <div class="layui-table-cell laytable-cell-1-anid100"><span>累计交易量</span></div>
                                </th>
                                <#--累计交易金额、累计转账、用户状态、注册日期、操作-->
                                <th data-field="totalDealCount">
                                    <div class="layui-table-cell laytable-cell-1-9"><span>累计交易金额</span></div>
                                </th>
                                <th data-field="totalTransferCount">
                                    <div class="layui-table-cell laytable-cell-1-anid90"><span>累计转账</span></div>
                                </th>
                                <th data-field="registerTime" data-unresize="true">
                                    <div class="layui-table-cell laytable-cell-1-publistTime"><span>注册时间</span></div>
                                </th>
                                <th data-field="9">
                                    <div class="layui-table-cell laytable-cell-1-9" align="center"><span>操作</span></div>
                                </th>
                            </tr>
                            </thead>
                            <tbody id="anList">
                            </tbody>
                        </table>
                        <div class="box-tools pull-right">
                            <ul class="pagination" id="pagination_ul">
                            </ul>
                        </div>

    </div>
</div>
</body>
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/layui/layui.js"></script>
<script type="text/javascript" src="/static/js/tools.js"></script>
<script type="text/javascript" src="/static/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="/static/js/CodeConst.js"></script>
<script type="text/javascript" src="/static/js/common.js"></script>
<script>
    //遍历baseDto
    function loadData(baseDto) {
        if (baseDto.code == ERROR)
            console.log(baseDto.msg);
        else {
            //数据
            var shareholderList = baseDto.data.list;
            var text = "";
            var opreate = "";
            var transferList = "";
            var dealList = "";
            var frozenAliceCount = "<td></td>\n";
            var bankList = "";
            console.log(shareholderList);
            $.each(shareholderList, function (index, shareholder) {
                //console.log(shareholder.userRealInfo.realName);
                //console.log(shareholder.realName)
                // if (shareholderList.userBankCardList != undefined && shareholderList.userBankCardList.length>0){
                //     bankList = " <a href='/back/admin/admin/userBankPage?userId=" + shareholder.user.id + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">银行卡详情</a>\n";
                // }
                transferList = "<a href='/back/admin/member/transferPage?userId=" + shareholder.user.id + "'   type=\"button\" class=\"layui-btn layui-btn-xs\">" + shareholder.totalTransferCount + "</a>\n";
                dealList = "<a href='/back/admin/member/dealHistoryPage?userId=" + shareholder.user.id + "'   type=\"button\" class=\"layui-btn layui-btn-xs\">" + shareholder.totalDealPrice + "</a>\n";
                if (shareholder.user.state == 0) {
                    frozenAliceCount = "<td>0</td>\n";
                    opreate = "<td class=\"text-center\" align=\"center\">\n" +
                        "    <a onclick='getClose(" + shareholder.user.id + ")'   type=\"button\" class=\"layui-btn layui-btn-xs\">封号</a>\n" +
                        "    <a onclick='getFrozen(" + shareholder.user.id + ")'  type=\"button\" class=\"layui-btn layui-btn-xs\">冻结</a>\n" +
                        "    <a href='/back/admin/admin/userBankPage?userId=" + shareholder.user.id + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">银行卡详情</a>\n" +
                        bankList +
                        "    <a href='/back/admin/member/memberInfoPage?userType=2&userId=" + shareholder.user.id + "'   type=\"button\" class=\"layui-btn layui-btn-xs\">用户信息</a>\n" +
                        "</td>\n"
                } else if (shareholder.user.state == 1) {
                    frozenAliceCount = "<td>" + shareholder.totalAliveCount + "</td>\n";
                    opreate = "<td class=\"text-center\" align=\"center\">\n" +
                        "    <a onclick='getClose(" + shareholder.user.id + ")'    type=\"button\" class=\"layui-btn layui-btn-xs\">封号</a>\n" +
                        "    <a onclick='getUnFrozen(" + shareholder.user.id + ")' type=\"button\" class=\"layui-btn layui-btn-xs\">解冻</a>\n" +
                        "    <a href='/back/admin/admin/userBankPage?userId=" + shareholder.user.id + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">银行卡详情</a>\n" +
                        bankList +
                        "    <a href='/back/admin/member/memberInfoPage?userType=2&userId=" + shareholder.user.id + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">用户信息</a>\n" +
                        "</td>\n"
                } else if (shareholder.user.state == 2) {
                    frozenAliceCount = "<td>0</td>\n";
                    opreate = "<td class=\"text-center\" align=\"center\">\n" +
                        "    <a onclick='getUnClose(" + shareholder.user.id + ")'  type=\"button\" class=\"layui-btn layui-btn-xs\">解封</a>\n" +
                        "    <a onclick='getFrozen(" + shareholder.user.id + ")'   type=\"button\" class=\"layui-btn layui-btn-xs\">冻结</a>\n" +
                        "    <a href='/back/admin/admin/userBankPage?userId=" + shareholder.user.id + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">银行卡详情</a>\n" +
                        bankList +
                        "    <a href='/back/admin/member/memberInfoPage?userType=1&userId=" + shareholder.user.id + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">用户信息</a>\n" +
                        "</td>\n"
                } else if (shareholder.user.state == 3) {
                    frozenAliceCount = "<td>0</td>\n";
                    opreate = "<td class='text-center' align='center' > \n" +
                        "    <a onclick='getActive(" + shareholder.user.id + ")'   type=\"button\" class=\"layui-btn layui-btn-xs\">激活</a>\n" +
                        "    <a href='/back/admin/admin/userBankPage?userId=" + shareholder.user.id + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">银行卡详情</a>\n" +
                        // "    <a href='/back/admin/admin/userDetailPage?userId=" + shareholder.user.id + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">用户详情</a>\n" +
                        // "    <a href='/back/admin/admin/userCapitalPage?userType=1&userId=" + shareholder.user.id + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">资产详情</a>\n" +
                        "</td>\n"
                }
                text += "<tr>\n" +
                    "<td>" + shareholder.user.id + "</td>\n" +
                    "<td>" + ((shareholder.userRealInfo == undefined) ? "" : shareholder.userRealInfo.realName) + "</td>\n" +
                    // "<td>" + (shareholder.userRealInfo && shareholder.userRealInfo.realName) ? shareholder.userRealInfo.realName : '' + "</td>\n" +
                    "<td>" + shareholder.phoneNum + "</td>\n" +
                    "<td>" + ((shareholder.userInfoBind.mail == undefined) ? "" : shareholder.userInfoBind.mail) + "</td>\n" +
                    "<td>" + shareholder.user.userTypeName + "</td>\n" +
                    "<td>" + shareholder.user.userStateName + "</td>\n" +
                    "<td>" + shareholder.totalAliveCount + "</td>\n" +
                    frozenAliceCount +
                    "<td>" + shareholder.totalDealCountOne + "</td>\n" +
                    "<td>" + dealList + "</td>\n" +
                    "<td>" + transferList + "</td>\n" +
                    "<td>" + shareholder.user.createTime + "</td>\n" +
                    opreate +
                    "</tr>";
            });
            console.log(opreate)
            var anListDom = $("#anList");
            anListDom.empty();//清空子元素
            anListDom.append($(text));
            // var pages = baseDto.data.pages;
            // var pageNum = baseDto.data.pageNum;
            // console.log("pageNum=" + pageNum);
            // var btnList = "";
            // btnList += "<li class='first_page'><a onclick='loadPage(this)' link='/back/content/an/list'>" + "首页" + "</a></li>";
            // var temp = "<li class='prepage'><a onclick='loadPage(this)' link='/back/content/an/list?pageNum=" + (pageNum - 1) + "'>上一页</a></li>";
            // console.log("temp=" + temp);
            // btnList += temp;
            // for (var i = 0; i < pages; i++) {
            //     btnList += ("<li class='prepage'><a onclick='loadPage(this)' link='/back/content/an/list?pageNum=" + (i + 1) + "'>" + (i + 1) + "</a></li>\n")
            // }
            // btnList += ("<li class='nextpage'><a onclick='loadPage(this)' link='/back/content/an/list?pageNum=" + (pageNum + 1) + "'>下一页</a></li>\n" +
            //     "<li class='last_page' ><a onclick='loadPage(this)' link='/back/content/an/list?pageNum=" + pages + "'>末页</a></li>");
            // console.log(btnList);
            // var pagination_ul = $("#pagination_ul");
            // pagination_ul.empty();
            // pagination_ul.append(btnList);

        }
    }

    function getUnFrozen(userId) {
        //获取数据
        $.ajax({
            url: "/back/admin/admin/active",
            type: "GET",
            dataType: "json",
            data: {
                userId: userId,
                userType: 1
            },
            success: function () {
                init();
            }
        });
    }

    function loadPage(a) {
        var a_jquery = $(a);
        var url = a_jquery.attr("link");
        $.ajax(
            {
                url: url,
                type: "GET",
                success: function (baseDto) {
                    loadData(baseDto);
                }
            }
        );
    }

    // function init() {
    //     $.ajax({
    //         url: "/back/admin/member/list",
    //         type: "GET",
    //         success: function (baseDto) {
    //             loadData(baseDto);
    //         }
    //     });
    // }
    //
    // init();

    function getMemberList() {
        var minDealedCount = $("#minDealedCount").val();
        var maxDealedCount = $("#maxDealedCount").val();
        var minAliveCoinCount = $("#minAliveCoinCount").val();
        var maxAliveCoinCount = $("#maxAliveCoinCount").val();
        var endRegisterTime = $("#endRegisterTime").val();
        var startRegisterTime = $("#startRegisterTime").val();
        //获取数据
        $.ajax({
            url: "/back/admin/member/sift",
            type: "GET",
            dataType: "json",
            data: {
                minDealedCount: minDealedCount,
                maxDealedCount: maxDealedCount,
                minAliveCoinCount: minAliveCoinCount,
                maxAliveCoinCount: maxAliveCoinCount,
                endRegisterTime: endRegisterTime,
                startRegisterTime: startRegisterTime
            },
            success: function (baseDto) {
                loadData(baseDto);
            }
        });
    }

    function getClose(userId) {
        //获取数据
        $.ajax({
            url: "/back/admin/admin/close",
            type: "GET",
            dataType: "json",
            data: {
                userId: userId
            },
            success: function () {
                console.log("封号");
                window.location.reload();
            }
        });
    }

    function getUnClose(userId) {
        //获取数据
        $.ajax({
            url: "/back/admin/admin/unclose",
            type: "GET",
            dataType: "json",
            data: {
                userId: userId
            },

            success: function () {
                console.log("解封");
                window.location.reload();
            }

        });
    }

    function getFrozen(userId) {
        //获取数据
        $.ajax({
            url: "/back/admin/admin/frozen",
            type: "GET",
            dataType: "json",
            data: {
                userId: userId,
                userType: 1
            },
            success: function () {
                window.location.reload();
            }
        });
    }


    function getActive(userId) {
        //获取数据
        $.ajax({
            url: "/back/admin/admin/active",
            type: "GET",
            dataType: "json",
            data: {
                userId: userId
            },
            success: function () {
                window.location.reload();
            }
        });
    }

    layui.use(['form', 'laydate','laypage', 'layer'], function () {
        var form = layui.form;
        var laydate = layui.laydate;
        var laypage = layui.laypage;

        $.ajax({
            url: "/back/admin/member/search",
            type: "GET",
            success: function (baseDto) {
                loadData(baseDto);
                baseDto = baseDto.data;
                laypage.render({
                    elem: 'pagination_ul'
                    , count: baseDto.total
                    , curr: baseDto.fristPage //获取起始页
                    , limit: 10
                    , jump: function (obj) {
                        loadPage(obj.curr);
                    }

                });
            }
        });

        function loadPage(pageNum) {
            $.get("/back/admin/member/search?pageNum=" + pageNum, function (baseDto) {
                loadData(baseDto);
            })
        }

        form.render('select', 'memberState');
        laydate.render({
            elem: '#endRegisterTime',
            type: 'datetime'
        });



        $.ajax({
            url: "/back/admin/member/list",
            type: "GET",
            success: function (baseDto) {
                loadData(baseDto);
                baseDto = baseDto.data;
                laypage.render({
                    elem: 'pagination_ul'
                    ,count: baseDto.total
                    ,curr: baseDto.fristPage //获取起始页
                    ,limit: baseDto.pageSize
                    ,jump: function (obj) {
                        loadPage(obj.curr);
                    }

                });
            }
        });


        function loadPage(pageNum)
        {
            $.get("/back/admin/member/searchPage?pageNum="+pageNum,function (baseDto) {
                loadData(baseDto);
            })
        }
        laydate.render({
            elem: '#startRegisterTime',
            type: 'datetime'
        });

        function search() {
            var userName = $("#userName").val();
            var phoneNum = $("#phoneNum").val();
            var idCardNum = $("#idCardNum").val();
            //获取数据
            $.ajax({
                url: "/back/admin/member/search",
                type: "GET",
                dataType: "json",
                data: {
                    userName: userName,
                    phoneNum: phoneNum,
                    idCardNum: idCardNum
                },
                success: function (baseDto) {
                    loadData(baseDto);
                }
            });
        }

    });
</script>
